cmake_minimum_required(VERSION 3.18)
project(ForeachDemo LANGUAGES CXX)

# 1. 遍历 items
message(STATUS "遍历 items")
foreach(X "1" "2;3;4" "abc" )
    message("X1: ${X}")
endforeach()

# 2. range stop
message(STATUS "范围遍历")
foreach(X RANGE 3)
    message("X2: ${X}")
endforeach()

# 3. range [l, r] step
message(STATUS "指定范围遍历")
foreach(X RANGE 10 20 3)
    message("X2: ${X}")
endforeach()

# 4 range Items
message(STATUS "遍历范围内元素")
foreach(X IN ITEMS "1" "2;3;4" "abc")
    message("X4 : ${X}")
endforeach()

# 5 range Lists
message(STATUS "遍历列表")
set(L1 "1")
set(L2 "2;3;4")
set(L3 "abc")
foreach(X IN LISTS L1 L2 L3)
    message("X5 : ${X}")
endforeach()
